package com.jwt.demo.base;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jwt.demo.sys.entity.User;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @author 林武杰
 * @date 2021/9/27 17:33
 */
public class BaseAbstractDao<E extends BaseEntity, M extends BaseMapper<E>> {

    @Autowired
    private M mapper;

    public int insert(Object entity) {
        return mapper.insert((E) entity);
    }


    public int deleteById(Serializable id) {
        return mapper.deleteById(id);
    }


    public int delete(Wrapper wrapper) {
        return mapper.delete(wrapper);
    }


    public int updateById(Object entity) {
        return mapper.updateById((E) entity);
    }


    public int update(Object entity, Wrapper updateWrapper) {
        return mapper.update((E) entity, updateWrapper);
    }


    public Object selectById(Serializable id) {
        return mapper.selectById(id);
    }


    public E selectOne(Wrapper queryWrapper) {
        return (E) mapper.selectOne(queryWrapper);
    }


    public Integer selectCount(Wrapper queryWrapper) {
        return mapper.selectCount(queryWrapper);
    }


    public List selectList(Wrapper queryWrapper) {
        return mapper.selectList(queryWrapper);
    }


    public List<Map<String, Object>> selectMaps(Wrapper queryWrapper) {
        return mapper.selectMaps(queryWrapper);
    }


    public List<Object> selectObjs(Wrapper queryWrapper) {
        return mapper.selectObjs(queryWrapper);
    }


    public IPage<Map<String, Object>> selectMapsPage(IPage page, Wrapper queryWrapper) {
        return mapper.selectMapsPage(page, queryWrapper);
    }


    public IPage selectPage(IPage page, Wrapper queryWrapper) {
        return mapper.selectPage(page, queryWrapper);
    }


    public List selectByMap(Map columnMap) {
        return mapper.selectByMap(columnMap);
    }


    public List selectBatchIds(Collection idList) {
        return mapper.selectBatchIds(idList);
    }


    public int deleteBatchIds(Collection idList) {
        return mapper.deleteBatchIds(idList);
    }


    public int deleteByMap(Map columnMap) {
        return mapper.deleteByMap(columnMap);
    }
}
